﻿using System;
using System.Web;
using System.Web.UI;
using System.Linq;
using System.Configuration;
using SharedLibraries.Donate;
using SharedLibraries;

namespace ThangNM.UserControl
{
    public partial class DonateUC : System.Web.UI.UserControl
    {
        private string merchant_site_code = "30713";
        private string merchant_pass = "tipshop303909";
        private string receiver = "thang.991992@gmail.com";
        Int64 lblTongtien = 0;
        String txtPay_FullName = "";
        String txtPay_PhoneNumber = "";
        String txtPay_Note = "";

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void Nganluong(String Orders_ID, Int32 SumQuantity)
        {
            Int64 lblTongtien = 0;
            NL_Checkout nlcheckout = new NL_Checkout();
            //nlcheckout.merchant_site_code = this.merchant_site_code;
            //nlcheckout.secure_pass = this.merchant_pass;
            //string rs = nlcheckout.buildCheckoutUrl("http://tipshop.tk/success.aspx", "thang.991992@gmail.com", txtPay_Note, Orders_ID, lblTongtien, "vnd", SumQuantity, 0, 0, 0, 0, "", "Nguyễn Mạnh Thắng*|*thang.991992@gmail.com*|*01675279562*|*", "");
            string rs = nlcheckout.buildCheckoutUrl("http://tipshop.tk/success.aspx", "thang.991992@gmail.com", txtPay_Note, Orders_ID, lblTongtien.ToString());
            Response.Write(rs);
            Response.Redirect(rs);
        }

        public void Paygate(String Orders_ID)
        {
            try
            {
                var Security_Key = ConfigurationManager.AppSettings["SecretKey"];
                string dataSign = string.Format("{0}-{1}-{2}-{3}-{4}-{5}-{6}", 505, 1, Orders_ID, Convert.ToInt32(lblTongtien), "01675279562", "", Security_Key);
                string signRSA = Security1.SHA256encrypt(dataSign);
                string listparam = string.Format("?website_id={0}&payment_method={1}&order_code={2}&amount={3}&receiver_acc={4}&customer_name={5}&customer_mobile={6}&order_des={7}&param_extend={8}&sign={9}",
                    505, 1, Orders_ID, Convert.ToInt32(lblTongtien), "01675279562",
                    txtPay_FullName, txtPay_PhoneNumber, txtPay_Note, "", signRSA);


                string urlRedirect = ConfigurationManager.AppSettings["VTCPay_Url"] + listparam;
                Response.Redirect(urlRedirect, false);

            }
            catch (Exception ex)
            {
                //Label1.Text = ex.ToString();
                NLogLogger.Info(ex.ToString());
            }
        }

        public void Baokim(String Orders_ID, Int32 SumQuantity)
        {
            BaoKimPayment BaoKimPayment = new BaoKimPayment();
            string rs1 = BaoKimPayment.createRequestUrl(Orders_ID, "thang.991992@gmail.com", lblTongtien.ToString(), "", "", txtPay_Note, "http://tipshop.tk/success.aspx", "http://tipshop.tk/error.aspx", "http://tipshop.tk/Customer/OrdersDetails.aspx?Orders_ID=" + Orders_ID);
            Response.Write(rs1);
            Response.Redirect(rs1);
        }
    }
}